#include "hzpch.h"
#include "Renderer.h"
#include "SourceCode/Renderer/Renderer2D.h"

namespace Hazal
{

	CRenderer::SSceneData* CRenderer::s_pSceneData = new CRenderer::SSceneData;

	void CRenderer::Init()
	{
		CRenderCommand::Init();
		CRenderer2D::Init();
	}

	void CRenderer::OnWindowResize(uint32_t unWidth, uint32_t unHeight)
	{
		CRenderCommand::SetViewport(unWidth, unHeight);
	}

	void CRenderer::BeginScene(COrthoGraphicCamera& rCamera)
	{
		s_pSceneData->viewProjMatrix = rCamera.GetViewProjMatrix();
	}

	void CRenderer::EndScene()
	{

	}

	void CRenderer::Submit(const Ref<CShader>& pShader, std::shared_ptr<CVertexArray>& pVertexArrray, const glm::mat4& transformMat)
	{
		pShader->Bind();
		pShader->SetMat4("u_viewProjction", s_pSceneData->viewProjMatrix);
		pShader->SetMat4("u_transform", transformMat);

		pVertexArrray->Bind();

		CRenderCommand::DrawIndexed(pVertexArrray);
	}

	void CRenderer::Shutdown()
	{
		CRenderer2D::Shutdown();
	}


}